Enable Error Handling in .NET Report Engine
The .NET Report Engine API includes a facility for collecting and displaying warnings and errors that occur while it is generating output. This article describes what the verify and error handling features do, with some examples of the warnings and errors they capture.
This article also describes the API calls used to enable error handling, and provides example code based on one of our Catapult C# example command-line applications.
The relevant API calls are the TrackErrors property and GetErrorInfo().
#
What Does It Do?The verify feature provides you with actionable information on non-fatal errors, warnings, and other issues contained within a Report Template that occur when generating output with .NET Report Engine.
Error handling is a Tag property that can be set to catch errors and exceptions that occur in a Tag's query. Depending on the error-handling Tag property setting, otherwise fatal errors can be captured and ignored so output can be completed despite the error. For more details about the error-handling Tag property, see the Out Tag Reference.<!---NEEDS LINK to out tag reference doco--->
#
Example Warnings and ErrorsHere are some examples of the warnings and errors captured when the verify and error handling features are used:
Data Type Issues
warning: ‘Buchanan’ is String while NUMBER expected: <wr:out select=’SELECT dbo.Emplayees.LastName FROM dbo.Employees’ type=’NUMBER’ nickname='TypeError’ error-handling=‘Ignore type error;lgnore formatting error;Ignore select error;Node must exist’ datasource=’MSSQL’/>
warning: ‘Buchanan’ is String while NUMBER expected: <wrout select=’SELECT dbo.Emplayees.LastName FROM dbo.Employees’ type=‘NUMBER’ nickname='TypeError’ error-handling=‘Ignore type error;lgnore formatting error;Ignore select error;Node must exist’ datasource=’MSSQL’/>
Formatting Issues
warning: format(Buchanan, ) is not allowed: <wr:out select=’SELECT dbo.Employees.LastName FROM dbo.Employees’ type=‘NUMBER' nickname=TypeError’ error-handling= Ignore type error;Ignore formatting error;Iqnore select error;Node must exist’ datasource=’MSSQL’/>
warning: Could not parse: Adam: <wr:out select='/Formats-to-test/Author/Firstname’ type=‘DATE’ format=‘categary-date-type:0-format:m/d/yyyy’; nickname=’FORMAT_PROBLEM' error-handling=‘Ignore formatting error;Ignore select error’ datasource='TestingDatabase'/>
warning: format(Buchanan, ) is not allowed: <wr:out select=’SELECT dbo.Employees.LastName FROM dbo.Employees’ type=’NUMBER’ nickname=’TypeError’ error-handling=’Ignore type error;Ignore formatting error;Iqnore select error,Node must exist’ datasource=’MSSQL’/>
warning: Could not parse: Adam: <wr:out select='/Formats-to-test/Author/Firstname’ type=‘DATE’ format=‘categary-date-type:0-format:m/d/yyyy’; nickname=’FORMAT_PROBLEM' error-handling=‘Ignore formatting error;Ignore select error’ datasource='TestingDatabase'/>
Bad Select Statement
warning: Invalid column name ‘dbo’. Final select: select dbo from dbo.Employees: <wr:out select=‘select dbo from dbo.Employees’ nickname=‘DNE1' error-handling=’Ignore select error’ datasource=‘MSSQL’/>
warning: Invalid column name ‘dbo’. Final select: select dbo from dbo.Employees: <wr:out select=‘select dbo from dbo.Employees’ nickname=‘DNE1' error-handling=’Ignore select error’ datasource=‘MSSQL’/>
Node Does Not Exist
error: The tag returned no nodes: <wr:out select='/Formats-to-test/Nada’ nickname=‘Nadal' error-handling='Node must exist’ datasource=’TestingDatabase’/>
error: The tag returned no nodes: <wr:out select='/Formats-to-test/Nada’ nickname=‘Nadal' error-handling='Node must exist’ datasource=TestingDatabase’/>
Node Is Null
warning: The tag is empty: <wr:out select=‘select ShipRegion from dbo.Orders where OrderID=10248’ nickname=‘[ShipRegion]’ error-handling=‘Node must not return NULL’ datasource=‘MSSQL’/>
warning: The tag is empty: <wr:out select=‘select ShipRegion from dbo.Orders where OrderID=10248’ nickname=‘[ShipRegion]’ error-handling=‘Node must not return NULL’ datasource=‘MSSQL’/>
Verification Issues
warning: Tag uses undefined data source ‘OData’: <wr:set select=‘Employees?$select=Nada&$top=1' var='varName3’ nickname=‘DNE8' error-handling=‘Ignore select error’ datasource='OData’/>
warning: Tag uses undefined data source ‘OData’: <wr:set select=‘Employees?$select=Nada&$top=1' var='varName3’ nickname=‘DNE' error-handling=‘Ignore select error’ datasource='OData'/>
#
TrackErrorsTrackErrors is used to enable error handling in your .NET Report Engine application:
TrackErrors is declared in the net.windward.xmlreport.errorhandling namespace.
#
TrackErrors FlagsHere are the values to which the TrackErrors property can be set:
#
GetErrorInfo()GetErrorInfo() is used to process any warnings and errors that occur while .NET Report Engine is running, after TrackErrors is used to turn on error handling:
GetErrorInfo() is also declared in the net.windward.xmlreport.errorhandling namespace.
#
RunReportXml.cs ExampleHere is the source file RunReportXml.cs from our Catapult C# command-line examples, with error handling added and NEW COMMENTS IN ALL CAPS: